<template>
  <div>
    <el-table
      :cell-style="{'text-align':'center'}"
      :header-cell-style="{'text-align':'center'}"
      stripe
      border
      size="mini"
      :data="tableData.filter(data => !search || data.activity_name.toLowerCase().includes(search.toLowerCase()))"
      style="width: 100%"
      height="95vh"
    >
      <el-table-column
        label="创建日期"
        width="200"
        prop="create_time">
      </el-table-column>
      <el-table-column
        label="活动名称"
        width="200"
        prop="activity_name">
      </el-table-column>
      <el-table-column
        label="创建用户"
        width="200"
        prop="user_name">
      </el-table-column>
      <el-table-column
        label="用户账号"
        width="200"
        prop="user_account">
      </el-table-column>
      <el-table-column
        label="活动类型"
        width="200"
        prop="activity_type">
      </el-table-column>
      <el-table-column
        label="参与方式"
        width="200"
        prop="activity_intoWay">
      </el-table-column>
      <el-table-column
        label="参与地址"
        width="200"
        prop="activity_address">
      </el-table-column>

      <el-table-column
        label="活动评分"
        width="80"
        prop="activity_score">
      </el-table-column>
      <el-table-column
        label="是否通过"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.check ===1?'':'danger'">  {{scope.row.check ===1?'是':'否'}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        width="150"
        align="right"
        fixed="right">
        <template slot="header" >
          编辑
          <el-input
            v-model="search"
            size="mini"
            placeholder="输入关键字搜索"/>
        </template>
        <template slot-scope="scope">
          <div> <el-button
            size="mini"
            @click="handleAllow(scope.row.id,scope.$index, tableData)">审核通过</el-button></div>
          <div class="mt-1"> <el-button
            size="mini"
            type="danger"
            @click="handleRefuse(scope.row.id,scope.$index, tableData)">拒绝通过</el-button></div>

        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

export default {
  data() {
    return {
      search: '',
      getActivityStore: this.newStore(),
      refuseStore: this.newStore(),
      AllowStore: this.newStore(),
      num: 105,
      page: 0,
      tableData: [],

    };
  },
  created() {
    this.getActivity();
  },
  methods: {
    handleRefuse(id, index, rows) {
      this.spost(this.getActivityStore, '/Admin/ActivityEditor', { id, num: 2 }).then(() => {
        this.$message.success('操作成功！');
        rows[index].check = 2;
      });
    },
    handleAllow(id, index, rows) {
      this.spost(this.getActivityStore, '/Admin/ActivityEditor', { id, num: 1 }).then(() => {
        this.$message.success('操作成功！');
        rows[index].check = 1;
      });
    },
    getActivity() {
      this.spost(this.getActivityStore, '/Admin/getActivity', { num: this.num, page: this.page }).then((res) => {
        this.tableData = res.d.MoodList;
      });
    },
  },
};
</script>

<style scoped lang="scss">

</style>
